<!DOCTYPE html>
<html>
<body>
<script>
if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}
var dragIcon = document.createElementNS("http://www.w3.org/2000/svg", "img");
</script>
<p>Tests dragging an SVG image.  Test passes if the test does not crash.</p>
<img id="elementToDrag" src="resources/abe.png" draggable="true" ondragstart="dragStart(event);" onload="runTest()"/>
<div id="dragTarget" ondragenter="dragEnter(this);" style="width: 300px; height: 300px; border: 1px solid gray;"></div>
<script>
function dragStart(event)
{
    event.dataTransfer.setDragImage(dragIcon, -10, -10);
}

function dragEnter(div)
{
    div.innerText = "Success - drag entered";
    if (window.testRunner)
        testRunner.notifyDone();
}

function runTest()
{
    var elementToDrag = document.getElementById("elementToDrag");
    var x1 = elementToDrag.offsetLeft + elementToDrag.offsetWidth / 2;
    var y1 = elementToDrag.offsetTop + elementToDrag.offsetHeight / 2;

    eventSender.mouseMoveTo(x1, y1);
    eventSender.mouseDown();

    var dragTarget = document.getElementById("dragTarget");
    var x2 = dragTarget.offsetLeft + dragTarget.offsetWidth / 2;
    var y2 = dragTarget.offsetTop + dragTarget.offsetHeight / 2;

    eventSender.mouseMoveTo(x2, y2);
    eventSender.mouseUp();
}
</script>
</body>
</html>
